{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Compiling Extension Modules on Windows using mingw\n",
      "==================================================\n",
      "\n",
      "Pre-reqs\n",
      "--------\n",
      "\n",
      "1. Python 2.5 (with earlier versions of Python, it is much more complicated to compile extensions with mingw. Use visual Studio 2003 if you cannot upgrade to Python 2.5)\n",
      "2. Local admin access on your machine\n",
      "\n",
      "Compiler setup\n",
      "--------------\n",
      "\n",
      "1. Go to www.mingw.org and go to the \"downloads\" section of the web-site. Look for the link to the sourceforge page and go there. Grab the latest version of the \"Automated MinGW Installer\" and run the installer.\n",
      "2. When asked \"which MinGW package\" you would like to install, select \"Current\" or \"Candidate\" depending on whether you want to be on the bleeding edge or not.\n",
      "3. When you get to the section where you need to select the various components you want to install, include the \"base tools\" and the \"g++ compiler\", and possibly the g77 compiler too if you are going to be compiling some extensions that use Fortran.\n",
      "4. Install it to \"C:\\MinGW\" (the default location)\n",
      "5. Add \"C:\\MinGW\\bin\" to your PATH environment variable if the installer did not do this for you.\n",
      "   If you are running Vista, you will need to add \"C:\\MinGW\\libexec\\gcc\\mingw32\\3.4.5\" to your PATH as well\n",
      "6. In notepad (or your favourite text editor) create a new text file and enter the following in the file:\n",
      "\n",
      "       [build]\n",
      "       compiler = mingw32\n",
      "\n",
      "7. Save the file as \"C:\\Python25\\Lib\\distutils\\distutils.cfg\". This will tell python to use the MinGW compiler when compiling extensions\n",
      "8. Close down any command prompts you have open (they need to be reopened to see the new environment variable values)\n",
      "\n",
      "Compiling an extension (through distutils)\n",
      "------------------------------------------\n",
      "\n",
      "Note: this will only work for modules which have a setup.py script that uses distutils\n",
      "\n",
      "1. So lets say you have downloaded code for some module to the folder \"xyz\". Open a command prompt and cd to this directory (eg. type \"c:\" then press enter to change to the C drive, then type \"cd c:\\xyz\" to change to directory xyz)\n",
      "2. To create a binary installer, type \"python setup.py bdist_wininst\"\n",
      "3. If everything worked fine, then there should now be a subfolder called \"dist\" which contains an exe file that you can run to install the module.\n"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}